<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/11/9
 * Time: 15:22
 */
use Phalcon\Config\Adapter\Ini as ConfigIni;
use Phalcon\Mvc\Application;
use Phalcon\Session\Adapter\Files as Session;
use Phalcon\Di\FactoryDefault;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
// ...

// Read the configuration
$config = new ConfigIni(APP_PATH . 'app/config/config.ini');

require APP_PATH . 'app/config/loader.php';

$loader = new Phalcon\Loader();
$loader->registerDirs(
    array(
        APP_PATH . $config->application->controllersDir,
        APP_PATH . $config->application->pluginsDir,
        APP_PATH . $config->application->librayDir,
        APP_PATH . $config->application->modelsDir,
        APP_PATH . $config->application->formsDir,
    )
)->register();

$app = new Application($di);
echo $app->handle()->getContent();

$id->set('session', function(){
    $session = new Session();
    $session->start();
    return $session;
});

$di = new FactoryDefault();
/*
 * $di->set('db', function() use ($config)){
   return new DbAdapter(
       array(
           "host"     => $config->database->host,
           "username" => $config->database->username,
           "password" => $config->database->password,
           "dbname"   => $config->database->name
       )
   );
});



*/